package org.beyondscript.demo.design;

import cn.hutool.json.JSONUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @program: org.beyondscript.demo.design
 * @description: 多种类型商品不同接口，统一发奖服务搭建场景
 * @author: lilf@bwoil.com
 * @create: 2024-06-05 17:02
 **/
public class PrizeController {

    private Logger logger = LoggerFactory.getLogger(PrizeController.class);

    public AwardRes awardToUser(AwardReq req){
        String reqJson = JSONUtil.toJsonStr(req);
        AwardRes awardRes = null;
        try {
            logger.info("奖品发放开始{}。reqJson={}", req.getuId(), reqJson);
            // 按照不同类型方法商品[1优惠券、2实物商品、3第三方兑换卡(爱奇艺)]
            if(req.getAwardType() == 1){

                awardRes = new AwardRes("0000", "发放成功");

            }else if(req.getAwardType() == 2){

            }else if(req.getAwardType() == 3){

            }
            logger.info("奖品发放完成{}。reqJson={}", req.getuId(), reqJson);
        } catch (Exception e) {
            logger.error("奖品发放失败。reqJson={}", reqJson, e);
        }
        return awardRes;
    }

    private String queryUserName(String uId){
        return "花花";
    }

    private String queryUserPhoneNumber(String uId){
        return "18038071234";
    }

}
